package com.itheima.thread.communication.demo04;

import java.util.concurrent.locks.ReentrantLock;

public class CustomerThread implements Runnable {

    private Box box;
    private ReentrantLock reentrantLock;
    public CustomerThread(Box box, ReentrantLock reentrantLock) {
        this.box = box;
        this.reentrantLock = reentrantLock;
    }

    @Override
    public void run() {
        while (true) {
            reentrantLock.lock();
            System.out.println(box.getMilkType() + "," + box.getAmount());
            reentrantLock.unlock();
        }
    }
}
